package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import com.xbongbong.saas.domain.entity.WorkOrderFlowUserEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * 工单用户model
 * @author 魏荣杰
 * @date 2019/3/11 16:39
 * @since v1.0
 * @version v1.0
 */
public interface WorkOrderFlowUserModel extends IModel<WorkOrderFlowUserEntity> {
    @Override
    Integer insert(WorkOrderFlowUserEntity entity) throws XbbException;

    @Override
    Integer update(WorkOrderFlowUserEntity entity) throws XbbException;

    @Override
    List<WorkOrderFlowUserEntity> findEntitys(Map<String, Object> param);

    @Override
    Integer getEntitysCount(Map<String, Object> param);

    /**
     * Description: 根据工单id获取工单团队的用户ids
     * @param workOrderId 工单id
     * @param corpid 公司id
     * @param isMain 是否是负责人，1查负责人，0协同人，不填查所有
     * @return java.util.List<java.lang.String>
     * @author 魏荣杰
     * @date 2019/4/3 14:14
     * @since v1.0
     */
    List<String> getTeamUserIdList(Long workOrderId, String corpid, Integer isMain);

    void delete(Map<String, Object> param) throws XbbException;

    void delete(WorkOrderFlowUserEntity entity) throws XbbException;
    /**
     * Description: 批量删除根据工单id（包括es）
     * @param corpid
     * @param workOrderIdIn
     * @param userIdList
     * @return java.lang.Integer
     * @throws XbbException XbbException
     * @author 魏荣杰
     * @date 2019/5/5 20:55
     * @since v1.0
     */
    Integer batchDeleteByWorkOrderId(String corpid, List<Long> workOrderIdIn, List<String> userIdList) throws XbbException;

    /**
     * Description: 批量插入工单用户数据（包括es）
     * @param workOrderFlowUserEntityList
     * @throws XbbException XbbException
     * @author 魏荣杰
     * @date 2019/5/5 20:55
     * @since v1.0
     */
    void insertBatch(List<WorkOrderFlowUserEntity> workOrderFlowUserEntityList) throws XbbException;

    void insertBatch(List<WorkOrderFlowUserEntity> workOrderFlowUserEntityList, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * 查询协同团队基础列表
     *
     * @param map 参数
     * @return 团队
     */
    List<UserTeamEntity> findBaseEntitys(Map<String,Object> map);

    Integer save(WorkOrderFlowUserEntity entity) throws XbbException;

    WorkOrderFlowUserEntity getByKey(Long key, String corpid);

    /**
     * Description: 获取工单团队主键id
     * @param workOrderId 工单id
     * @param corpid 公司id
     * @param isMain 可为null,1主负责人 0协同人
     * @return java.util.List<java.lang.Long>
     * @author 魏荣杰
     * @date 2019/5/24 9:58
     * @since v1.0
     */
    List<Long> getTeamIds(Long workOrderId, String corpid, Integer isMain);

    List<Long> getWorkOrderIdByUserIdIn(String corpid, List<String> userIds, Integer isMain);

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    List<WorkOrderFlowUserEntity> getUserListByWorkorderId(String corpid, Long id);

    void deleteBatchById(List<Long> ids, String corpid);

    void updateBatch(List<WorkOrderFlowUserEntity> list, String corpid) throws XbbException;

    void deleteBatch(List<WorkOrderFlowUserEntity> userEntities, String corpid, Integer del) throws XbbException;
}
